﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ariregistri_toimik_Request", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(AriregistriToimikRequest))]
    public class AriregistriToimikRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAriregistriToimikRequest clazz;
        
        public AriregistriToimikRequestSerializer(IAriregistriToimikRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("ariregistri_kood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.AriregistriKood))).ToString());
            Writer.WriteEndElement();
            if (clazz.Keel!=null) {
                Writer.WriteStartElement("keel");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Keel))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Formaat!=null) {
                Writer.WriteStartElement("formaat");
                Writer.WriteTypeAttribute("http://producers.arireg.xtee.riik.ee/producer/arireg", "x_formaat");
                Writer.WriteString(clazz.Formaat.ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ariregistri_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ariregistri_toimik_Request>ariregistri_kood");
                }
                clazz.AriregistriKood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ariregistri_kood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_Request>ariregistri_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="keel") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Keel = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("keel")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="formaat") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Formaat = new global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.XFormaat(Reader.ReadElementString("formaat"));
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
